define(function (require, exports, module)
{
  var $ = require('jquery');
  var jxbaseinfo = require('jxbaseinfo');
  var $BarKit =
          {
            defaults:{
              site:jxbaseinfo.path,
              value:10,
              time:1000,
              cyc:10,
              info:''
            },
            barValue: 0,
            infoFmt: '[[bar_value]]%',
            waitTime: null,
            show: function (config)
            {
              config = $.extend({},this.defaults,config) ;
              if ($("#GI_PROGRESS_BAR").length == 0)
              {
                $.ajax({
                  async: false,
                  url: config.site + 'common/kit/progressbar.html', //这里是静态页的地址
                  type: "GET", //静态页用get方法，否则服务器会抛出405错误
                  success: function (data) {
                    $(document.body).append(data);
                  }
                });
              }
              this.barValue = config.value;
              var strInfo = config.info ;
              if (strInfo == '')
                strInfo = this.infoFmt.replace('[[bar_value]]', this.barValue);
              this.next(this.barValue,strInfo);
              $("#GI_PROGRESS_BAR").show();
              if (config.time >0)
              {
                this.waitTime = setInterval(function()
                {
                  $BarKit.barValue +=config.cyc ;
									if ($BarKit.barValue>=90)
									{
										clearInterval($BarKit.waitTime);
									}
                  var strInfo = config.info ;
                  if (strInfo == '')
                    strInfo = $BarKit.infoFmt.replace('[[bar_value]]', $BarKit.barValue);                  
                  $BarKit.next($BarKit.barValue,strInfo);
                },config.time)
              }
            },        
            next: function (value, info)
            {
              $("#DIV_GI_PROGRESS_BAR").attr("style", 'width:' + value + '%');
              $("#SPAN_GI_PROGRESS_BAR").html(info);
            },
            hide: function ()
            {
              $("#GI_PROGRESS_BAR").hide();
              if (this.waitTime != null)
                clearInterval(this.waitTime);
            }
          };

  return $BarKit;
});